(bug 13752) Section redirects now works again
authorAlexandre Emsenhuber <ialex@users.mediawiki.org>
Tue, 15 Apr 2008 17:32:23 +0000 (17:32 +0000)
committerAlexandre Emsenhuber <ialex@users.mediawiki.org>
Tue, 15 Apr 2008 17:32:23 +0000 (17:32 +0000)
RELEASE-NOTES
includes/Article.php
includes/Wiki.php

index 8e91c1e..1fbc6c4 100644 (file)
@@ -183,7 +183,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * (bug 13736) Don't show MediaWiki:Anontalkpagetext on non-existant IP addresses
 * (bug 13728) Don't trim initial whitespace during section edits
 * (bug 13727) Don't delete log entries from recentchanges on page deletion
-
+* (bug 13752) Section redirects now works again
 
 === API changes in 1.13 ===
 
index 3d444c2..02c3cd6 100644 (file)
@@ -71,7 +71,7 @@ class Article {
                        return $this->mRedirectTarget;
 
                # Query the redirect table
-               $dbr = wfGetDb(DB_SLAVE);
+               $dbr = wfGetDB(DB_SLAVE);
                $res = $dbr->select('redirect',
                                array('rd_namespace', 'rd_title'),
                                array('rd_from' => $this->getID()),
@@ -95,7 +95,7 @@ class Article {
                $retval = Title::newFromRedirect($this->getContent());
                if(!$retval)
                        return null;
-               $dbw = wfGetDb(DB_MASTER);
+               $dbw = wfGetDB(DB_MASTER);
                $dbw->insert('redirect', array(
                                'rd_from' => $this->getID(),
                                'rd_namespace' => $retval->getNamespace(),
@@ -105,10 +105,18 @@ class Article {
        }
 
        /**
+        * Get the Title object this page redirects to
+        *
+        * @param bool $getFragment should the fragment be set on the title
         * @return mixed false, Title of in-wiki target, or string with URL
         */
-       function followRedirect() {
-               $rt = $this->getRedirectTarget();
+       function followRedirect( $getFragment = false ) {
+               if( $getFragment )
+                       // We'll need to use the content of this page, as Article::getRedirectTarget()
+                       // now loads the data from redirect table, wich doesn't store the fragment
+                       $rt = Title::newFromRedirect( $this->getContent() );
+               else
+                       $rt = $this->getRedirectTarget();
 
                # process if title object is valid and not special:userlogout
                if( $rt ) {
index 5559f0a..49aaec9 100644 (file)
@@ -270,7 +270,6 @@ class MediaWiki {
         *
         * @param Title $title
         * @param Request $request
-        * @param string $action
         * @return mixed an Article, or a string to redirect to another URL
         */
        function initializeArticle( &$title, $request ) {
@@ -289,7 +288,7 @@ class MediaWiki {
 
                        // Follow redirects only for... redirects
                        if( $article->mIsRedirect ) {
-                               $target = $article->followRedirect();
+                               $target = $article->followRedirect( true /* getFragment */ );
                                if( is_string( $target ) ) {
                                        if( !$this->getVal( 'DisableHardRedirects' ) ) {
                                                // we'll need to redirect